import $http from '@/utils/request.js'
import dayjs from 'dayjs'
const endTime = dayjs(new Date().valueOf()).format('YYYY-MM-DD')
// index 页面 -------------------------------
// 获取售货机列表
export const listOfVendingMachinesAPI = (params) => {
  return $http({
    url: '/api/vm-service/vm/search',
    params
  })
}
// 售货机类型列表(搜索)
export const vendingMachineSearchAPI = () => {
  return $http({
    url: '/api/vm-service/vmType/search',
    params: {
      pageIndex: 1,
      pageSize: 100000
    }
  })
}
// 选择点位列表
export const selectAPointAPI = () => {
  return $http({
    url: '/api/vm-service/node/search',
    params: {
      pageIndex: 1,
      pageSize: 100000
    }
  })
}
// 新增售货机
export const addedVendingMachinesAPI = (data) => {
  return $http({
    url: '/api/vm-service/vm',
    method: 'POST',
    data
  })
}
// 策略管理
export const policyManagementAPI = () => {
  return $http({
    url: '/api/vm-service/policy'
  })
}
// 应用策略
export const applyThePolicy = (data) => {
  return $http({
    url: '/api/vm-service/vm/applyPolicy',
    method: 'PUT',
    data
  })
}
// 售货机类型详情
export const detailsOfVendingMachineTypeAPI = (typeId) => {
  return $http({
    url: `/api/vm-service/vmType/${typeId}`
  })
}
// 获取售货机货道详情
export const cargoChannelDetailsAPI = (innerCode) => {
  return $http({
    url: `/api/vm-service/channel/channelList/${innerCode}`
  })
}
// 商圈列表
export const smartFilteringAPI = (id) => {
  return $http({
    url: `/api/vm-service/businessType/name/${id}`
  })
}
// 获取商圈下销量前10的商品(补货推荐)
export const topSalesAPI = (businessId) => {
  return $http({
    url: `/api/vm-service/sku/businessTop10/${businessId}`
  })
}
// 查询售货机策略
export const vendingMachineStrategyAPI = (innerCode) => {
  return $http({
    url: `/api/vm-service/policy/vmPolicy/${innerCode}`
  })
}
// 点位信息
export const mapApi = () => {
  return $http({
    url: '/api/vm-service/node/search',
    params: {
      pageIndex: 1,
      pageSize: 100000
    }
  })
}
// 修改售货机点位
export const mapsAPI = (id, nodeId) => {
  return $http({
    url: `/api/vm-service/vm/${id}/${nodeId}`,
    method: 'PUT'
  })
}

// 搜索售货机(售货机列表)
export const MachinesAPI = (params) => {
  return $http({
    url: '/api/vm-service/vm/search',
    params
  })
}
// /api/order-service/report/orderCount
// 订单总数
export const totalNumberOfOrders = (innerCode) => {
  return $http({
    url: '/api/order-service/report/orderCount',
    params: {
      start: '2022-10-01 00:00:00',
      end: `${endTime} 23:59:59`,
      innerCode
    }
  })
}
// 获取一定时间范围之内的收入
export const moneyAPI = (innerCode) => {
  return $http({
    url: '/api/order-service/report/orderAmount',
    params: {
      start: '2022-10-01 00:00:00',
      end: `${endTime} 23:59:59`,
      innerCode
    }
  })
}
// 获取售货机补货次数
export const numberOfReplenishmentsAPI = (innerCode) => {
  return $http({
    url: `/api/task-service/task/supplyCount/${innerCode}/2022-10-01/${endTime}`
  })
}
// 维修次数
export const maintenanceNumberAPI = (innerCode) => {
  return $http({
    url: `/api/task-service/task/repairCount/${innerCode}/2022-10-01/${endTime}`
  })
}
// 获取售货机商品销量
export const productSalesAPI = (innerCode) => {
  return $http({
    url: `/api/order-service/report/skuCollect/${innerCode}/2022-10-01/${endTime}`
  })
}

// 售货机
export const vendingMachineAPI = (params) => {
  return $http({
    url: '/api/vm-service/vmType/search',
    params
  })
}
// 图片上传
export const imgAPI = (formdata) => {
  return $http({
    url: '/api/vm-service/sku/fileUpload',
    method: 'POST',
    formdata
  })
}
// 新增设备
export const addNewDevicesAPI = (data) => {
  return $http({
    url: '/api/vm-service/vmType',
    method: 'POST',
    data
  })
}
export const editDevicesAPI = (data, id) => {
  return $http({
    url: `/api/vm-service/vmType/${id}`,
    method: 'PUT',
    data
  })
}
export const deleDevicesAPI = (id) => {
  return $http({
    url: `/api/vm-service/vmType/${id}`,
    method: 'DELETE'
  })
}

// 选择商品
export const kepalaveAPI = (params) => {
  return $http({
    url: '/api/vm-service/sku/search',
    params
  })
}
// 终极表单添加
export const addList = ({ channelList, innerCode }) => {
  return $http({
    url: '/api/vm-service/channel/channelConfig',
    method: 'PUT',
    data: {
      channelList,
      innerCode
    }
  })
}
// /api/vm-service/channel/channelConfig
